package com.maxmlr.music.system.controller;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.beans.factory.annotation.Autowired;
import com.maxmlr.music.system.service.PictureService;
import com.maxmlr.music.system.entity.Picture;
import io.swagger.annotations.*;

import java.io.Serializable;

/**
 * @author max
 * @version 1.0
 * @ClassName AdminPictureController
 * @Description  页面跳转控制器
 * @Copyright Copyright (c) 2020: www.maxmlr.com.
 * @since 2020-06-14
 */
@Slf4j
@Controller
@Api(value = "/system/picture", tags = "Picture 页面跳转控制器")
@RequestMapping("/system/picture")
public class AdmPictureController {

    @Autowired
    public PictureService service;

    /**
     *  功能列表主页
     *
     * @return string
     */
    @GetMapping
    @RequiresPermissions("system:picture:picture")
    public String picture() {
        return "system/picture/picture";
    }

    /**
     *  添加页面
     *
     * @return string
     */
    @GetMapping("/add")
    @RequiresPermissions("system:picture:add")
    public String add(){
        return "system/picture/add";
    }

    /**
     *  编辑页面
     *
     * @return string
     */
    @GetMapping("/edit/{id}")
    @RequiresPermissions("system:picture:edit")
    public String edit(@PathVariable("id") Serializable id , Model model) {
        Picture picture = service.getById(id);
        model.addAttribute("picture", picture);
        return "system/picture/edit";
    }


}
